package com.huike.web.controller.clues;

import com.huike.clues.domain.mpVO.MPFalseClueVo;
import com.huike.clues.domain.vo.MpAssignmentVo;
import com.huike.clues.service.MpCluesService;
import com.huike.common.core.controller.BaseController;
import com.huike.common.core.domain.AjaxResult;
import com.huike.common.core.page.TableDataInfo;
import com.huike.common.entity.MPTbClue;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description TODO
 * @Author 何俊杰
 * @Date 2023-08-29 8:45
 */
@Api(tags = "线索管理相关接口")
@RestController
@RequestMapping("/clues/clue")
@Slf4j
public class CluesController extends BaseController {

	@Autowired
	private MpCluesService mpCluesService;

	/**
	 * 新增线索管理
	 *
	 * @param clue
	 * @return
	 */
	@ApiOperation("新增线索管理")
	@PostMapping
	public AjaxResult add(@RequestBody MPTbClue clue) {
		return AjaxResult.success(mpCluesService.add(clue));
	}


	/**
	 * 批量分配
	 * @param mpAssignmentVo
	 * @return
	 */
	@ApiOperation("批量分配")
	@PutMapping("/assignment")
	public AjaxResult assignment(@RequestBody MpAssignmentVo mpAssignmentVo){
		return AjaxResult.success(mpCluesService.assignment(mpAssignmentVo));
	}

	/**
	 * 查询线索管理列表
	 * @param mpTbClue
	 * @return
	 */
	@ApiOperation("查询线索管理列表")
	@GetMapping("/list")
	public TableDataInfo list(MPTbClue mpTbClue){
		startPage();
		List<MPTbClue> list = mpCluesService.selectClue(mpTbClue);
		return getDataTablePage(list);
	}

	/**
	 * 修改线索管理
	 * @param mpTbClue
	 * @return
	 */
	@ApiOperation("修改线索管理")
	@PutMapping
	public AjaxResult edit(@RequestBody MPTbClue mpTbClue){
		return AjaxResult.success(mpCluesService.updateMpTbClue(mpTbClue));
	}

	/**
	 * 线索转商机
	 * @param id
	 * @return
	 */
	@ApiOperation("线索转商机")
	@PutMapping("changeBusiness/{id}")
	public AjaxResult changeBusiness(@PathVariable Long id){
		return AjaxResult.success(mpCluesService.changeBusiness(id));
	}

	/**
	 * 伪线索
	 * @param id
	 * @return
	 */
	@ApiOperation("伪线索")
	@PutMapping("/false/{id}")
	public AjaxResult falseId(@PathVariable Long id, MPFalseClueVo falseClueVo){
		return AjaxResult.success(mpCluesService.falseId(id,falseClueVo));
	}

}
